package com.dacool.dialog;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dacool.app.sale.R;
import com.dacool.config.Config;
import com.dacool.model.Region;

public class PickCityDialog extends BasePickerDialog {

	private ArrayList<Region> mRegions = new ArrayList<Region>();
	
	public PickCityDialog setRegions(ArrayList<Region> regions) {
		this.mRegions = regions;
		return this;
	}

	public PickCityDialog(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		lv.setAdapter(new ArrayAdapter<String>(getContext(), 0) {
			@Override
			public int getCount() {
				// TODO Auto-generated method stub
				return mRegions.size();
			}

			@Override
			public View getView(int position, View convertView, ViewGroup parent) {
				if (convertView == null) {
					RelativeLayout layout = (RelativeLayout) LayoutInflater
							.from(getContext()).inflate(
									R.layout.basedialoglistitem, null);
					TextView tv = (TextView) layout
							.findViewById(R.id.textLabel);
					convertView = layout;
					convertView.setTag(tv);
				}
				TextView tv = (TextView) convertView.getTag();
				tv.setText(mRegions.get(position).name);
				return convertView;
			}

		});

	}
}
